# -*- coding: utf-8 -*-
#  @author  Bink
#  @date  2021/4/13 10:40 上午
#  @Email : 2641032316@qq.com

import tensorflow as tf

# with tf.Session() as sess:
#   print(sess.run(tf.random_normal([3,4])))
#   print("100个0的一维向量")
#   print(sess.run(tf.zeros([100])))
#   print("784x100矩阵每个值[1,1]之间")
#   print(sess.run(tf.random_normal([784,100],-1,1)))

# print(sess.run(tf.random_normal([3,4])))
# print("100个0的一维向量")
# print(sess.run(tf.zeros([100])))
# print("784x100矩阵每个值[1,1]之间")
# print(sess.run(tf.random_normal([784,100],-1,1)))
# with tf.Session() as sess:

# matrix1 = tf.constant([[3., 3.]])
# print("matrix1:", matrix1)
# matrix2 = tf.constant([[2.], [2.]])
# print("matrix2:", matrix2)
# product = tf.matmul(matrix1, matrix2)
# sess = tf.Session()
# result = sess.run(product)
# print("result:", result)
# matrix1 = sess.run(matrix1)
# print("matrix1:", matrix1)
# matrix2 = sess.run(matrix2)
# print("matrix2:", matrix2)
# sess.close()
# with tf.Session() as sess:
#     result = sess.run(product)
#     print("result", result)

# state = tf.Variable(0, name="counter")
# one = tf.constant(1)
# new_value = tf.add(state, one)
# update = tf.assign(state, new_value)
# init_op = tf.initialize_all_variables()
# with tf.Session() as sess:
#     sess.run(init_op)
#     print(sess.run(state))
#     for _ in range(3):
#         sess.run(update)
#         print(sess.run(state))

# input1 = tf.constant([1.0, 2.0, 3.0], name="X_const")  # 常量
# input2 = tf.Variable([3.0, 4.0, 5.0], name="y_var")  # 变 量必须有初值
# output = tf.add(input1, input2, name="add_op")
# # sess = tf.Session()  # 运行计算图之前创建session
# # result = sess.run(output, feed_dict={input2: [6.0, 6.0, 6.0]})
# # print("result: ", result, ",type: ", type(result))
#
# # init_op = tf.global_variables_initializer()
# init_op = tf.initialize_all_variables()
# # 调用 sess 的 ‘run()' 方法来执行矩阵乘法 op,feed 用来传入变量数据
# sess = tf.Session()  # 运行计算图之前创建session
# sess.run(init_op)
# result = sess.run(output)
# print(result)
#
# sess.close()

import numpy as np

x = tf.placeholder(tf.float32, [2, 50], name='originalx')
y = tf.placeholder(tf.float32, [2, 50], name='originaly')
# x = tf.placeholder([2, 50], name='originalx')
# y = tf.placeholder([2, 50], name='originaly')
c = x + y
with tf.Session() as sess:
    a = np.random.randint(0, 80, 100).reshape((2, 50))
    # print(np.random.randint(0, 80, 100).shape)
    aa = np.random.random(100).reshape((2, 50))
    # print(np.random.random(100).shape)
    result = sess.run(c, feed_dict={x: a, y: aa})
    # print(a.shape)
    print('a:\n', a)
    print('aa:\n', aa)
    print('result:\n', result)
